﻿<div class="box unit-overview account">
    <header>
        <h3><a href="@Url.Action(Loc.Act("Show").Set(new
        {
            id = JDM.Int32(Model.Account.EntityID)
        }).Localized())">@JDM.String(Model.Account.Username)</a></h3>
    </header>
    <section>
    @if(Model.ForumMember != null)
    {
        Html.RenderPartial("_Avatar", (object)Model.ForumMember);
    }
    </section>
    <section>
        <table class="key-value highlight-key">
            <tr>
                <td>
                    <label>@T(Res.Name("Created"))</label>
                </td>
                <td>
                    @Svc.Date((DateTime)JDM.DateTime(Model.Account.CreatedOn))
                </td>
            </tr>
            @{
                var attrFullName = (Model.Account.Attributes as IEnumerable<dynamic>)
                    .Where(x => JDM.String(x.Key) == Par.In("WebPortal").Of("Profile").Name("FullName"))
                    .Select(x => (string)JDM.String(x.Value))
                    .SingleOrDefault();
                if(!String.IsNullOrWhiteSpace(attrFullName))
                {
                    <tr>
                        <td>
                            <label>@T(Res.Name("FullName"))</label>
                        </td>
                        <td>
                            @attrFullName
                        </td>
                    </tr>
                }
                if(Model.ForumMember != null)
                {
                    <tr>
                        <td>
                            <label>@T(Res.Name("ForumTopics"))</label>
                        </td>
                        <td>
                            @JDM.Int32(Model.ForumMember.TopicCount)
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label>@T(Res.Name("ForumPosts"))</label>
                        </td>
                        <td>
                            @JDM.Int32(Model.ForumMember.PostCount)
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label>@T(Res.Name("ForumKarma"))</label>
                        </td>
                        <td>
                            @JDM.Int32(Model.ForumMember.KarmaPoints)
                        </td>
                    </tr>
                    if(Model.ForumMember.Rank != null)
                    {
                        var t_rank = (Model.ForumMember.Rank.Translations as IEnumerable<dynamic>)
                            .SingleOrDefault(x => JDM.Int32(x.Language.EntityID) ==
                                JDM.Int32(Svc.Localization.Language.EntityID));
                        <tr>
                            <td>
                                <label>@T(Res.Name("ForumRank"))</label>
                            </td>
                            <td>
                                @(t_rank != null ? JDM.String(t_rank.Name) : JDM.String(Model.ForumMember.Rank.EntityID))
                            </td>
                        </tr>
                    }
                }
                if(Model.PublicationAuthor != null)
                {
                    <tr>
                        <td>
                            <label>@T(Res.Name("Blog"))</label>
                        </td>
                        <td>
                            <a href="@Url.Action(Loc.Act("Index").Ctrl("Post").Area("Blog").Set(new
                            {
                                id = JDM.Int32(Model.PublicationAuthor.EntityID)
                            }).Localized())">@JDM.Int32(Model.PublicationAuthor.PublicationCount)</a>
                        </td>
                    </tr>
                }
            }
        </table>
    </section>
</div>